module dice.render.structs;

/** An angle in degrees */
struct Degrees
{
	float degrees;
}

/** An angle in radians */
struct Radians
{
	float radians;
}

/** A colour with red, green, blue and alpha (opacity) values */
struct Colour
{
	/** Red, green, blue and alpha values */
	float r, g, b, a;
	
	/** Definitions of some common colours */
	static Colour black		= {0, 0, 0, 1};
	static Colour white		= {1, 1, 1, 1};
	static Colour blue		= {0, 0, 1, 1};
	static Colour green		= {0, 1, 0, 1};
	static Colour red		= {1, 0, 0, 1};
}

/** A colour simplified into a 32-bit format for smaller size and faster calculations */
struct Pixel
{
	ubyte a, r, g, b;
	
	static Pixel rgba (ubyte r, ubyte g, ubyte b, ubyte a)
	{
		return Pixel(a,r,g,b);
	}
	
	static Pixel rgb (ubyte r, ubyte g, ubyte b)
	{
		return rgba(r,g,b,255);
	}
}

/** A rectangle */
struct Rect
{
	/** Co-ordinates of the top left and bottom right corners */
	float x1, y1, x2, y2;
	
	/** Returns a rectangle that is larger (adds b to each edge) */
	Rect withBorder (float b)
	{
		return Rect(x1-b, y1-b, x2+b, y2+b);
	}
	
	/** Returns this rectangle's size */
	Size size ()
	{
		return Size(x2-x1, y2-y1);
	}
	
	/** Returns true if the rectangle contains the given point */
	bool contains (float x, float y)
	{
		return x >= x1 && x <= x2 && y >= y1 && y <= y2;
	}
}

/** A shape with parallel top and bottom edges */
struct Trapezium
{
	float top, bottom;
	float topLeft, topRight;
	float bottomLeft, bottomRight;
}

/** A point or position */
struct Point
{
	/** Co-ordinates */
	float x, y;
}

/** A size */
struct Size
{
	/** Width and height */
	float w, h;
}
